package com.web.listener;

import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import javax.servlet.annotation.WebListener;
@WebListener
public class MyApplicationListener  implements ServletContextListener{
	@Override
	public void contextInitialized(ServletContextEvent event) {
		System.out.println("===1. 应用加载....");
		String path = event.getServletContext().getContextPath();
		System.out.println(path);
		//获取初始化参数
		String value = event.getServletContext().getInitParameter("username");
		String location = event.getServletContext().getInitParameter("contextConfigLocation");
		System.out.println("username--->"+value);
		System.out.println("contextConfigLocation--->"+location);
	}

	@Override
	public void contextDestroyed(ServletContextEvent event) {
		System.out.println("===2. 应用销毁....");
		String contextPath = event.getServletContext().getContextPath();
		System.out.println(contextPath);
	}

}
